package com.ostrich.module_home.ui

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.alibaba.android.arouter.facade.annotation.Route
import com.gyf.immersionbar.ImmersionBar
import com.ostrich.library_base.BaseFragment
import com.ostrich.library_common.route.RouterFragmentPath
import com.ostrich.module_home.R
import com.ostrich.module_home.adapter.HomeFragmentAdapter
import com.ostrich.module_home.daily.DailyFragment
import com.ostrich.module_home.databinding.HomeFragmentHomeBinding
import com.ostrich.module_home.discovery.DiscoveryFragment
import com.ostrich.module_home.nominate.NominateFragment

@Route(path = RouterFragmentPath.PAGER_HOME)
class HomeFragment :BaseFragment<HomeFragmentHomeBinding>() {
    private val titles = mutableListOf<String>()
    private val fragments = mutableListOf<Fragment>()
    private lateinit var homeFragmentAdapter: HomeFragmentAdapter

    init {
        titles+="发现"
        titles+="推荐"
        titles+="日报"
        fragments+=DiscoveryFragment()
        fragments+=NominateFragment()
        fragments+=DailyFragment()
    }

    override fun initView() {
        binding?.let {
            homeFragmentAdapter = HomeFragmentAdapter(titles,fragments,childFragmentManager)
            it.vpHomeContent.adapter = homeFragmentAdapter
            it.tabLayout.setupWithViewPager(it.vpHomeContent)
            it.vpHomeContent.currentItem = 1
        }

    }

    override fun initData() {

    }

    override fun initListener() {

    }

    override fun bindLayout(): Int {
       return R.layout.home_fragment_home
    }

    override fun onResume() {
        super.onResume()
        ImmersionBar.with(this)
            .fitsSystemWindows(true)
            .statusBarColor(R.color.white)
            .autoStatusBarDarkModeEnable(true,0.2f)
            .init()
    }


}